package com.jiangyg.mall.authz.feign;

import com.jiangyg.mall.authz.feign.fallback.AuthzFeignServiceFallbackFactory;
import com.jiangyg.mall.core.constant.HttpConstant;
import com.jiangyg.mall.core.support.restful.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 类描述：访问权限校验 Feign 客户端
 *
 * @author jiangyg
 * @date 2022-09-01
 */
@FeignClient(name = "mall-authz", url="http://192.168.20.13:8080/", fallbackFactory = AuthzFeignServiceFallbackFactory.class, contextId = "authz")
public interface AuthzFeignService {

    /**
     * 功能描述：校验当前用户是否有指定路径的访问权限
     *
     * @param path         待校验请求路径
     * @param attachParams 附加参数（此参数已经没用了，为了以后试验就不删除了）
     * @return Result<Object> 返回结果
     */
    @PostMapping(value = "authentication", headers = HttpConstant.CONTENT_TYPE_JSON)
    Result<String> authentication(@RequestParam("path") String path, @RequestBody Map<String, Object> attachParams);

}
